<template>
	<view class="all">
		<view class="" v-for="i in list">

			<view class="top-content">
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">课程名称</text>
					</view>
					<text class="item-ipt">{{i.course_name}}</text>
				</view>
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">时间</text>
					</view>
					<text class="item-ipt">{{i.createtime_text}}</text>
				</view>
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">地点</text>
					</view>
					<text class="item-ipt">{{i.place}}</text>
				</view>
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">组织部门</text>
					</view>
					<text class="item-ipt">{{i.department}}</text>
				</view>
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">培训人</text>
					</view>
					<text class="item-ipt">{{i.people}}</text>
				</view>
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">培训方式</text>
					</view>
					<text class="item-ipt">{{i.mode}}</text>
				</view>
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">培训对象</text>
					</view>
					<text class="item-ipt">{{i.object}}</text>
				</view>
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">培训目的</text>
					</view>
					<text class="item-ipt">{{i.objective}}</text>
				</view>
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">培训内容</text>
					</view>
					<view class="item-content">
						<text class="" v-for="v in i.content">{{v}}</text>
					</view>
				</view>
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">应到人数</text>
					</view>
					<text class="item-ipt">{{i.should_num}}</text>
				</view>
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">实到人数</text>
					</view>
					<text class="item-ipt">{{i.actual_num}}</text>
				</view>
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">培训效果</text>
					</view>
					<text class="item-ipt">{{i.effect}}</text>
				</view>
				<view class="content-item">
					<view class="title">
						<text class="point"></text>
						<text class="item-title">培训总结</text>
					</view>
					<text class="item-ipt">{{i.summary}}</text>
				</view>
			</view>
			<view class="doc" v-if="i.file.length>0">
				<image class="docFile" v-for="v,ind in i.file" @tap="openFile(v)" src="../../static/word.png" mode="">
				</image>
			</view>
			<!-- <view class="doc" v-if="i.file.length>0">
				<image class="docFile" v-for="v,ind in i.file" @tap="previewImage(i.file,ind)" src="../../static/word.png" mode="">
				</image>
			</view> -->
			<view class="doc" v-if="i.image.length>0">
				<image class="docimg" v-for="v,ind in i.image" @tap="previewImage(i.image,ind)" :src="v" mode="">
				</image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad(e) {
			this.init(e.id)
		},
		methods: {
			init(id) {
				let _this = this
				uni.request({
					url: this.$url + 'relevant.train_study/getTrainStudyInfoById',
					method: 'GET',
					header: {
						token: uni.getStorageSync('token')
					},
					data: {
						id: id
					},
					success: (res) => {
						if (res.data.code == 1) {
							_this.list = [res.data.data]
							for (let i = 0; i < _this.list.length; i++) {
								_this.list[i].content = _this.list[i].content.split('；')
							}
						}
					}
				})
			},
			previewImage(img, index) {
				uni.previewImage({
					urls: img,
					current: index
				})
			},
			openFile(file) {
				var _this = this
				uni.downloadFile({
					url: file,
					success: (res) => {
						console.log(res);
						if (res.statusCode == 200) {
							uni.openDocument({
								filePath: res.tempFilePath,
								success: () => {
									// _this.$showToast('打开文档成功')
								},
								fail: () => {
									_this.$showToast('暂不支持此类型文件')
								}
							})
						}
					},
					fail: (err) => {
						_this.$showToast('暂不支持此类型文件')
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.all {
		background: #F1F1F1;
		min-height: 100vh;

		.top-content {
			.content-item {
				display: flex;
				background: #FFFFFF;
				justify-content: space-between;
				border-bottom: 1px solid #DDDDDD;
				padding: 32rpx 32rpx;
				align-items: center;

				.title {
					width: 150rpx;
					display: flex;
					align-items: center;
					margin-right: 80rpx;

					.point {
						width: 8rpx;
						height: 8rpx;
						background: #003690;
						border-radius: 50%;
						margin-right: 14rpx;
					}

					.item-title {
						font-size: 28rpx;
						font-family: Source Han Sans SC;
						font-weight: 400;
						color: #333333;
					}
				}


				.item-ipt {
					// width: 400rpx;
					// text-align: end;
					flex: 1;
					font-size: 24rpx;
					font-family: Source Han Sans SC;
					font-weight: 400;
					color: #555555;
				}

				.item-content {
					flex: 1;
					display: flex;
					flex-wrap: wrap;

					text {
						font-size: 24rpx;
						font-family: Source Han Sans SC;
						font-weight: 400;
						color: #555555;
						margin-right: 30rpx;
					}
				}
			}
		}

		.doc {
			display: flex;
			align-items: center;
			padding: 20rpx 40rpx;
			background: #FFFFFF;
			margin-top: 20rpx;

			.docimg {
				width: 60rpx;
				height: 60rpx;
				margin-right: 20rpx;
			}

			.docFile {
				width: 50rpx;
				height: 60rpx;
				margin-right: 20rpx;
			}
		}
	}
</style>
